/**
 * 
 */
package com.hxf.common;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;

/**
 * http连接工具类
 * @author tengyicheng
 * @version [1.0, 2013/09/22]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class HttpHelper {

	private HttpHelper() {
	}

	/**
	 * 简单调用URL,并将返回结果
	 * 
	 * @param url
	 * @return
	 * @throws Exception
	 */
	public static String accessUrl(String url) throws Exception {
		URL U = new URL(url);
		URLConnection connection = U.openConnection();
		connection.connect();

		BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
		String line;
		StringBuilder sb = new StringBuilder();
		while ((line = in.readLine()) != null) {
			sb.append(line);
		}
		in.close();
		
		return sb.toString();
	}
}
